package com.lp.user.config;

import com.lp.model.constants.MQConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MQUserConfig {

    @Bean
    public DirectExchange userDirectExchange() {
        return new DirectExchange(MQConstants.USER_EXCHANGE_DIRECT, true, false);
    }

    @Bean
    public Queue followQueue() {
        return new Queue(MQConstants.USER_FOLLOW_QUEUE, true);
    }

    @Bean
    public Binding followBind() {
        return BindingBuilder.bind(followQueue()).to(userDirectExchange())
                .with(MQConstants.USER_FOLLOW_QUEUE);
    }


}
